home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / mach / errstring.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  2.6 KB  |  101 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log: errstring.c,v $
  29.  * Revision 1.1  1993/11/30  17:35:58  roland
  30.  * entered into RCS
  31.  *
  32.  * Revision 2.3  92/04/01  19:38:18  rpd
  33.  *     Updated do_compat for kernel device errors,
  34.  *     bootstrap file-system errors.
  35.  *     [92/03/09            rpd]
  36.  * 
  37.  * Revision 2.2  92/02/20  15:58:08  elf
  38.  *     Created from mach_error.c.
  39.  *     [92/02/11            rpd]
  40.  * 
  41.  */
  42.  
  43. #define EXPORT_BOOLEAN
  44. #include <mach/boolean.h>
  45. #include <mach/error.h>
  46. #include <mach_error.h>
  47. #include <errorlib.h>
  48.  
  49. extern void __mach_error_map_compat (mach_error_t *);
  50.  
  51. const char *
  52. mach_error_type( err )
  53.     mach_error_t        err;
  54. {
  55.     int sub, system;
  56.  
  57.     __mach_error_map_compat( &err );
  58.  
  59.     sub = err_get_sub(err);
  60.     system = err_get_system(err);
  61.  
  62.     if (system > err_max_system
  63.     ||  sub >= errors[system].max_sub ) return( "(?/?)" );
  64.     return( errors[system].subsystem[sub].subsys_name );
  65. }
  66.  
  67. boolean_t mach_error_full_diag = FALSE;
  68.  
  69. const char *
  70. mach_error_string_int( err, diag )
  71.     mach_error_t        err;
  72.     boolean_t        * diag;
  73. {
  74.     int sub, system, code;
  75.  
  76.     __mach_error_map_compat( &err );
  77.  
  78.     sub = err_get_sub(err);
  79.     system = err_get_system(err);
  80.     code = err_get_code(err);
  81.  
  82.     *diag = TRUE;
  83.  
  84.     if (system > err_max_system) return( "(?/?) unknown error system" );
  85.     if (sub >= errors[system].max_sub) return( errors[system].bad_sub );
  86.     if (code >= errors[system].subsystem[sub].max_code) return ( NO_SUCH_ERROR );
  87.  
  88.     *diag = mach_error_full_diag;
  89.     return( errors[system].subsystem[sub].codes[code] );
  90. }
  91.  
  92. const char *
  93. mach_error_string( err )
  94.     mach_error_t        err;
  95. {
  96.     boolean_t diag;
  97.  
  98.     return mach_error_string_int( err, &diag );
  99.  
  100. }
  101.